package demo04;

import java.util.Scanner;

interface Container {
    public static final double pi=3.1415926;
    public abstract double area();
    public abstract double volume();

    static double sumofArea(Container c[]) {
        return 0;
    }

    static double sumofVolume(Container c[]) {
        return 0;
    }
}


class Cube implements Container{
    Scanner sc=new Scanner(System.in);


    @Override
    public double area() {
        double a=sc.nextDouble();

        return a*a*6;
    }

    @Override
    public double volume() {
        double a=sc.nextDouble();

        return a*a*a;
    }
}
 class Cylinder implements Container{
    Scanner sc=new Scanner(System.in);


    @Override
    public double area() {
        double a=sc.nextDouble();
        double b=sc.nextDouble();
        return 2*pi*a*b+2*pi*a*a;
    }

    @Override
    public double volume() {
        double a=sc.nextDouble();
        double b=sc.nextDouble();
        return pi*a*a*b;
    }

}



class test {
    public static void main(String[] args) {
        double sum1=0;
        double sum2=0;
        Scanner sc=new Scanner(System.in);
        int n= sc.nextInt();
        for(int i=0;i<n;i++)
        {
            String name=sc.next();
            if(name == "Cube")
            {
                Cube m=new Cube();
                sum1+=m.area();
                m.volume();
                sum2+=m.volume();
            }
            else
            {
                Cube m=new Cube();
                sum1+=m.area();
                m.volume();
                sum2+=m.volume();
            }

        }
        System.out.println(sum1);
        System.out.println(sum2);


    }



}